package indi.gao.springAopTest.service.student;

import indi.gao.springAopTest.dao.ScoreDao;
import indi.gao.springAopTest.model.Score;
import indi.gao.springAopTest.model.Student;
import indi.gao.springAopTest.service.score.ScoreService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

/**
 * @author :gaolei
 * @version :v1.0
 * @projectName :GLUtil
 * @description :
 * @createDate :2021/10/19 3:02 下午
 */
@Service
public class StudentService {

    @Resource
    private ScoreDao scoreDao;

    @Resource
    private ScoreService scoreService;

    @Transactional(rollbackFor = Exception.class)
    public void insertStudent(Student student) {
        Score score = new Score();
        score.setScore("100");
        score.setName(student.getStudentName());
        scoreService.insertScore(score);
        student.setStudentScoreId(score.getId());
        student.setId(System.currentTimeMillis());
        scoreDao.insertStudent(student);
    }
}
